<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./js-calendar-converter.js"></script>
  <script src="https://cdn.bootcss.com/jquery/3.5.0/jquery.js"></script>
  <script src="./wannianli.js"></script>
</head>
<body>
  <div class="wrapper">
    <p>阳历生日
      <input type="datetime-local" class="cdate" name="dataTime" value="1995-09-21T05:43"></p>
      <p>或</p>
    <p>阴历生日
      <input type="datetime-local" class="ldate" name="dataTime" value="1995-09-21T05:43"></p></p>
     
    <div class="result">
      <p>你的八字是：<span id="bazi"></span></p>
      <p>你的五行是：<span id="wx"></span></p>
    </div>
  </div>

<script>
  $('.cdate').on('change', (e) => {
    
    const [date, time] = e.target.value.split('T')
    const [y, m, d] = date.split('-')
    const [hour, minu] = time.split(':')
    const {lYear, lMonth, lDay} = calendar.solar2lunar(y, m, d) // 获取农历年

    const tar = {
      cYear: Number(y), //公历年份
      cMonth: Number(m), //公历月份
      cDay: Number(d), //公历日期
      lYear: lYear,
      lMonth: lMonth, //农历月份
      lDay: lDay, //农历日期
      hour: hour,
      minute: minu
    };

    var result = WanNianLi.getResult(tar);
    var {bazi, wuxing, wuxingResult} = result
    console.log(calendar.solar2lunar(y, m, d))
    console.log(result);
    

    $('#bazi').html(`${bazi.year}年 ${bazi.month}月 ${bazi.date}日 ${bazi.hour}时`)
  })
</script>
</body>
</html>